package com.hsmpay.mobile.action.added.zzy;

import com.hsmpay.common.pojo.qian4.Qian4SendLog;
import com.hsmpay.common.pojo.user.User;
import com.hsmpay.common.util.DateConvertUtil;
import com.hsmpay.common.util.JSONStringBuilder;
import com.hsmpay.common.util.URLDecoderTools;
import com.hsmpay.mobile.action.account.qian48.Q4BaseAction;
import com.hsmpay.mobile.action.added.AddedBaseAction;
import com.hsmpay.mobile.pojo.added.AddedOrder;
import com.hsmpay.mobile.pojo.terminal.TerminalPrivileges;
import com.hsmpay.mobile.util.icc.ME30DataDecode;
import com.hsmpay.utils.Des3;
import it.sauronsoftware.base64.Base64;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.hsmpay.qian4.pojo.PurchaseResult;
import com.hsmpay.utils.TimeUtils;

import java.net.URLEncoder;
import java.util.*;

//import zyzf.added.zzf.Watercoal;
//import zyzf.pay.qian4.utils.Qian48Constant;

/**
 * 掌中付 水电煤
 *
 * @author 颜铃璋
 */
@Controller("zzyWiolationAction")
@Scope("prototype")
public class ZzyWiolationAction extends AddedBaseAction {
    private static final long serialVersionUID = 5340784605432629434L;
    private static Logger log = Logger.getLogger(ZzyWiolationAction.class);
//	private static Watercoal watercoal = new Watercoal();

    private static Map<String, List<Map<String, String>>> provinceHashes = new HashMap<String, List<Map<String, String>>>();
    private static Map<String, Map<String, List<Map<String, String>>>> cityHashes = new HashMap<String, Map<String, List<Map<String, String>>>>();
    private static Map<String, Map<String, String>> allCityHash = new HashMap<String, Map<String, String>>();

    String deptWiliCode = "16W2";////本地缴费事业单位编号

    private String item;//00：水、01：电、02: 煤
    private String provinceId;//省ID
    private String cityId;//城市ID
    private String wiliCode;//本地缴费事业单位编号
    private String wltiId;//缴费事业单位对应关系编号
    private String payAmount;//代缴费应缴金额
    private String mobileNo;//缴费用户手机号
    //private String merchantOrderId;//商户订单号
    private String billTypeCode;//缴费单据编号类型 1：条形码，2：用户号（暂时只填）
    private String userNo;//代缴费单据编号（用户输入）
    private String channelId;//渠道编号
    private String channelKind;//渠道品牌
    private String isHaveBillDate;//是否输入账期 1 支持 0 不支持
    private String isHavePayAmount;//是否输入金额 1 为是，0 为否
    private String isPrePay;//是否支持预缴费 1 支持 0 不支持
    private String billDate;//账期
    private String extTypeCode;//缴费子类型码
    private String leePayAmount;//滞纳金
    private String balanceAmount;//上次余额
    private String twqtcId;//应缴费流水号
    private String contractNo;//费用合同号
    private String customerName;//客户名称
    private String wiliName;//单位名称

    /**
     * 初始化 省市
     * 00：水，01：电，02:煤
     */
    public void initArea() throws Exception {
        try {
//			resolveArea("00",watercoal.getAreaList("00"));
//			resolveArea("01",watercoal.getAreaList("01"));
//			resolveArea("02",watercoal.getAreaList("02"));
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

    /**
     * 解析省市范围
     *
     * @throws Exception
     */
    public void resolveArea(String item, String result) throws Exception {
        try {
            log.debug("初始化省市范围时：item = " + item + " result = " + result);
            List<Map<String, String>> provinceHash = new ArrayList<Map<String, String>>();
            Map<String, List<Map<String, String>>> cityHash = new HashMap<String, List<Map<String, String>>>();
            Map<String, String> allCityMap = new HashMap<String, String>();
            String tempProvince = null;
            List<Map<String, String>> cityList = null;
            Map<String, String> cityMap = null;
            Map<String, String> provinceMap = null;
            String[] resultA = result.split("##");
            if ("000".equals(resultA[0].split("\\|")[0])) {
                String[] provinceCityA = resultA[1].split("\\|");
                for (String pCity : provinceCityA) {
                    String[] pCityA = pCity.split("#");
                    for (int i = 0; i < pCityA.length; i++) {
                        String[] pA = pCityA[i].split(",");
                        if (i == 0) {
                            provinceMap = new HashMap<String, String>();
                            provinceMap.put("id", pA[1]);
                            provinceMap.put("name", pA[0]);
                            provinceHash.add(provinceMap);
                            tempProvince = pA[1];
                            cityList = new ArrayList<Map<String, String>>();
                            cityHash.put(tempProvince, cityList);
                            allCityMap.put(pA[1], pA[0]);
                        } else {
                            cityMap = new HashMap<String, String>();
                            cityMap.put("id", pA[1]);
                            cityMap.put("name", pA[0]);
                            cityHash.get(tempProvince).add(cityMap);
                            allCityMap.put(pA[1], pA[0]);
                        }
                    }
                }
            }
            provinceHashes.put(item, provinceHash);
            cityHashes.put(item, cityHash);
            allCityHash.put(item, allCityMap);//根据键 可以获得 省市值
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

    /**
     * 获得省
     *
     * @return
     * @throws Exception
     */
    public void getProvince() throws Exception {
        try {
//			clientType = Integer.parseInt(js.getString("clientType"));
//			terminalTypeId = Long.parseLong(js.getString("terminalTypeId"));
//			roleId = Long.parseLong(js.getString("roleId"));
            item = getJsonString("item");

            log.debug("item = " + item);
            if (StringUtils.isEmpty(item)) {
                log.info("获得省时, 传入参数item为空");
                sendAppErrorMsg("6001", "item");
                return;
            }

            if (provinceHashes.size() == 0) {
                initArea();
            }

            Map<String, Object> result = new LinkedHashMap<String, Object>();
            result.put("reqCode", "0000");
            result.put("reqMsg", "获得省成功！");
            List<Map<String, String>> provinceMap = provinceHashes.get(item);
            result.put("list", provinceMap);
            sendAppMsg(result);

        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

    /**
     * 获得市
     *
     * @return
     * @throws Exception
     */
    public void getCity() throws Exception {
        try {
            item = getJsonString("item");
            provinceId = getJsonString("provinceId");

            log.debug("item = " + item);
            log.debug("provinceId = " + provinceId);
            if (StringUtils.isEmpty(item)) {
                log.info("获得城市时, 传入参数item为空");
                sendAppErrorMsg("6001", "item");
                return;
            }
            if (StringUtils.isEmpty(provinceId)) {
                log.info("获得城市时, 传入参数provinceId为空");
                sendAppErrorMsg("6001", "provinceId");
                return;
            }

            if (0 == cityHashes.size()) {
                initArea();
            }

            Map<String, Object> result = new LinkedHashMap<String, Object>();
            result.put("reqCode", "0000");
            result.put("reqMsg", "获得城市成功！");
            Map<String, List<Map<String, String>>> cityMapEs = cityHashes.get(item);
            List<Map<String, String>> cityMap = cityMapEs.get(provinceId);
            result.put("list", cityMap);
            sendAppMsg(result);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

    /**
     * 获取缴费单位
     *
     * @throws Exception
     */
    public void getInstList() throws Exception {
        try {
            item = getJsonString("item");
            provinceId = getJsonString("provinceId");
            cityId = getJsonString("cityId");

            log.debug("item = " + item);
            log.debug("provinceId = " + provinceId);
            log.debug("cityId = " + cityId);
            if (StringUtils.isEmpty(item)) {
                log.info("获取缴费单位时, 传入参数item为空");
                sendAppErrorMsg("6001", "item");
                return;
            }
            if (StringUtils.isEmpty(provinceId)) {
                log.info("获取缴费单位时, 传入参数provinceId为空");
                sendAppErrorMsg("6001", "provinceId");
                return;
            }
            if (StringUtils.isEmpty(cityId)) {
                log.info("获取缴费单位时, 传入参数cityId为空");
                sendAppErrorMsg("6001", "cityId");
                return;
            }
//			Map<String,Object> result = watercoal.getInstList(item,provinceId,cityId);
//			sendAppMsg(result);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

    /**
     * 待缴费查询
     */
    public void queryNotify() throws Exception {
        try {
            item = getJsonString("item");
            provinceId = getJsonString("provinceId");
            cityId = getJsonString("cityId");
            wiliCode = getJsonString("wiliCode");
            billTypeCode = getJsonString("billTypeCode");
            userNo = getJsonString("userNo");
            mobileNo = getJsonString("mobileNo");
            channelId = getJsonString("channelId");
            channelKind = getJsonString("channelKind");
            wltiId = getJsonString("wltiId");
            isHaveBillDate = getJsonString("isHaveBillDate");
            isHavePayAmount = getJsonString("isHavePayAmount");
            isPrePay = getJsonString("isPrePay");
            billDate = getJsonString("billDate");
            amount = getJsonString("amount");

            log.debug("item = " + item);
            log.debug("provinceId = " + provinceId);
            log.debug("cityId = " + cityId);
            log.debug("wiliCode = " + wiliCode);
            log.debug("billTypeCode = " + billTypeCode);
            log.debug("userNo = " + userNo);
            log.debug("mobileNo = " + mobileNo);
            log.debug("channelId = " + channelId);
            log.debug("channelKind = " + channelKind);
            log.debug("wltiId = " + wltiId);
            log.debug("isHaveBillDate = " + isHaveBillDate);
            log.debug("isHavePayAmount = " + isHavePayAmount);
            log.debug("isPrePay = " + isPrePay);
            log.debug("billDate = " + billDate);
            log.debug("amount = " + amount);

            if (StringUtils.isEmpty(item)) {
                log.info("获取缴费单位时, 传入参数item为空");
                sendAppErrorMsg("6001", "item");
                return;
            }
            if (StringUtils.isEmpty(provinceId)) {
                log.info("获取缴费单位时, 传入参数provinceId为空");
                sendAppErrorMsg("6001", "provinceId");
                return;
            }
            if (StringUtils.isEmpty(cityId)) {
                log.info("获取缴费单位时, 传入参数cityId为空");
                sendAppErrorMsg("6001", "cityId");
                return;
            }
            if (StringUtils.isEmpty(wiliCode)) {
                log.info("获取缴费单位时, 传入参数wiliCode为空");
                sendAppErrorMsg("6001", "wiliCode");
                return;
            }
            if (StringUtils.isEmpty(billTypeCode)) {
                log.info("获取缴费单位时, 传入参数billTypeCode为空");
                sendAppErrorMsg("6001", "billTypeCode");
                return;
            }
            if (StringUtils.isEmpty(userNo)) {
                log.info("获取缴费单位时, 传入参数userNo为空");
                sendAppErrorMsg("6001", "userNo");
                return;
            }
            if (StringUtils.isEmpty(mobileNo)) {
                log.info("获取缴费单位时, 传入参数mobileNo为空");
                sendAppErrorMsg("6001", "mobileNo");
                return;
            }
            if (StringUtils.isEmpty(channelId)) {
                log.info("获取缴费单位时, 传入参数channelId为空");
                sendAppErrorMsg("6001", "channelId");
                return;
            }
            if (StringUtils.isEmpty(channelKind)) {
                log.info("获取缴费单位时, 传入参数channelKind为空");
                sendAppErrorMsg("6001", "channelKind");
                return;
            }
            if (StringUtils.isEmpty(wltiId)) {
                log.info("获取缴费单位时, 传入参数wltiId为空");
                sendAppErrorMsg("6001", "wltiId");
                return;
            }
            if (StringUtils.isEmpty(isHaveBillDate)) {
                log.info("获取缴费单位时, 传入参数isHaveBillDate为空");
                sendAppErrorMsg("6001", "isHaveBillDate");
                return;
            }
            if (StringUtils.isEmpty(isHavePayAmount)) {
                log.info("获取缴费单位时, 传入参数isHavePayAmount为空");
                sendAppErrorMsg("6001", "isHavePayAmount");
                return;
            }
            if (StringUtils.isEmpty(isPrePay)) {
                log.info("获取缴费单位时, 传入参数isPrePay为空");
                sendAppErrorMsg("6001", "isPrePay");
                return;
            }
            if (StringUtils.isEmpty(billDate)) {
                billDate = "";
            }
            if (StringUtils.isEmpty(amount)) {
                amount = "";
            }

            functionKey = "WATER_ELECTRICITY_PAYMENT";
            if (!checkPIV(functionKey)) {
                log.warn("缴费时, 接口暂停使用！");
                return;
            }

//			Map<String,Object> result = watercoal.QueryNotify(item, wiliCode, billTypeCode, userNo, mobileNo, channelId, channelKind, wltiId, isHaveBillDate, isHavePayAmount, isPrePay, billDate, amount);
//			sendAppMsg(result);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }


    /**
     * 缴费
     */
    public void gotoNotify() throws Exception {
        try {
            log.debug(getRequest().getAttribute(FC_DATA));
            terminalTypeId = Long.parseLong(getJsonString("terminalTypeId"));
            roleId = Long.parseLong(getJsonString("roleId"));
            clientType = Integer.parseInt(getJsonString("clientType"));
            userId = Long.parseLong(getJsonString("userId"));
            item = getJsonString("item");
            provinceId = getJsonString("provinceId");
            cityId = getJsonString("cityId");
            extTypeCode = getJsonString("extTypeCode");
            wiliCode = getJsonString("wiliCode");
            wltiId = getJsonString("wltiId");
            billTypeCode = getJsonString("billTypeCode");
            userNo = getJsonString("userNo");
            payAmount = getJsonString("payAmount");
            amount = getJsonString("amount");
            leePayAmount = getJsonString("leePayAmount");
            balanceAmount = getJsonString("balanceAmount");
            billDate = getJsonString("billDate");
            mobileNo = getJsonString("mobileNo");
            isPrePay = getJsonString("isPrePay");
            twqtcId = getJsonString("twqtcId");
            contractNo = getJsonString("contractNo");
            customerName = getJsonString("customerName");
            wiliName = getJsonString("wiliName");

//			if(js.containsKey("merchantOrderId"))
//				merchantOrderId = getJsonString("merchantOrderId");
            merchantOrderTime = getJsonString("merchantOrderTime");
            accountNumber = getJsonString("accountNumber");
            pin = getJsonString("pin");
            track2Data = getJsonString("track2Data");
            track3Data = getJsonString("track3Data");
            signaturePath = getJsonString("signaturePath");

            encryType = getJsonString("encryType");
            icCardYu = getJsonString("icCardYu");//IC卡 域
            transTerminalId = getJsonString("transTerminalId");//翰星终端ID

            functionKey = "WATER_ELECTRICITY_PAYMENT";
            if (!checkPIV(functionKey)) {
                log.warn("缴费时, 接口暂停使用！");
                return;
            }

            //屏蔽伪卡
            if (transRefuseCardService.isRefuseCard(accountNumber)) {
                sendAppErrorMsg("6073", accountNumber);
                return;
            }

            TerminalPrivileges tp = terminalPrivilegesService.searchPrivilegesByFunctionKey(functionKey);
            //IC卡
            Integer payTchannel = tp.getPayTchannel().intValue();
            if ("1".equals(encryType)) {
                track2Data = ME30DataDecode.decryptTrace2(track2Data);
                //icCardYu.replace(oldChar, newChar)
            } else if ("2".equals(encryType)) {
                String trackOData = getJsonString("trackOData");
                String[] trackA = ME30DataDecode.decryptTrace2_aic(trackOData, track2Data);
                track2Data = trackA[0];
                track3Data = trackA[1];
            }
            track2Data = track2Data.replaceAll("F", "");//屏蔽二磁道有F的情况

            Long orderTypeId = 60L;
            if ("01".equals(item)) orderTypeId = 61L;
            if ("02".equals(item)) orderTypeId = 62L;
            Date date = new Date();
            String orderNum = getOrderNumByDate(date);
            merchantOrderTime = DateConvertUtil.dateString(date, "yyyyMMddHHmmss");
            User user = userService.getUserById(userId);
            if (null != user) {
//				String dynamicKeyData= DesUtil.generate16Key();
//				String transType = "100000";
//				pin=DesUtil.encryptPin(merchantOrderTime, pin, Qian48Constant.pinKey);
//				track2Data=DesUtil.encryptStanderTranck(merchantOrderTime, dynamicKeyData, Qian48Constant.DesKey, track2Data);
//				byte[] desKey = DesUtil.compute3DES(DesUtil.hexStringToByte(Qian48Constant.macKey),DesUtil.hexStringToByte(merchantOrderTime + "80"));
//				String orgMacStr = accountNumber + " " + pin + " " + track2Data + " " + orderNum + " " + amount + " " + merchantOrderTime + " " +  transType;
//				//报文鉴别码
//				String mac=DesUtil.mac(DesUtil.byte2hex(desKey), orgMacStr);
                //组装 发送数据
                Qian4SendLog send = new Qian4SendLog();
                send.setCallType(0);
                send.setUserId(userId);
                send.setOrderTypeId(orderTypeId);
                send.setApplication("Purchase.Req");
                send.setTransType("100000");//
                send.setSendTime(date);
                send.setSendSeqId(TimeUtils.getTimeToString());
//				send.setMerchantId(Qian48Constant.merchantId);//商户代码 ##
//				send.setTerminalId(Qian48Constant.jianyi_terminalId);
//				send.setPlatformId(Qian48Constant.platformId);

                send.setMerchantOrderId(orderNum);//商户订单号
                send.setMerchantOrderTime(date);//商户订单号时间
                send.setTransTime(send.getSendTime());
                send.setTransAmt(amount);
                send.setCurrency("156");
                send.setAccountNumber(accountNumber);
                send.setPin(pin);
                send.setTrack2Data(track2Data);
                send.setTrack3Data(track3Data);
                //send.setCardholderSign(cardholderSign);//电子签名
//				send.setDynamicKeyData(dynamicKeyData);
//				send.setMac(mac);
                send.setCollectionType(payTchannel);
                send.setIp(URLDecoderTools.getRemoteHost(getRequest()));//IP
                send.setIcCardYu(icCardYu);
                send.setCardTypeN(StringUtils.isEmpty(icCardYu) ? 1 : 2);//1 磁条卡 2 IC卡
                send.setTransTerminalId(transTerminalId);

                AddedOrder order = new AddedOrder();
                order.setOrderNum(orderNum);
                order.setTerminalTypeId(terminalTypeId);
                order.setRoleId(roleId);
                order.setClientType(clientType);
                order.setOrderTypeId(orderTypeId);
                order.setUserId(userId);
                order.setTransMoney(Double.parseDouble(amount) / 100);
                order.setBankCard(accountNumber);
                order.setMobile(mobileNo);
                order.setStatus(3);
                order.setCreateDate(date);
                order.setLongTime(date.getTime());
                order.setSignaturePath(signaturePath);
                order.setChannelId(tp.getTchannel());
                Map<String, String> thirdParamMap = new HashMap<String, String>();
                thirdParamMap.put("item", item);
                thirdParamMap.put("provinceName", getCityName(item, provinceId));
                thirdParamMap.put("cityName", getCityName(item, cityId));
                thirdParamMap.put("extTypeCode", extTypeCode);
                thirdParamMap.put("wiliCode", wiliCode);
                thirdParamMap.put("wltiId", wltiId);
                thirdParamMap.put("billTypeCode", billTypeCode);
                thirdParamMap.put("userNo", userNo);
                thirdParamMap.put("payAmount", payAmount);
                thirdParamMap.put("amount", amount);
                thirdParamMap.put("leePayAmount", leePayAmount);
                thirdParamMap.put("balanceAmount", balanceAmount);
                thirdParamMap.put("billDate", billDate);
                thirdParamMap.put("mobileNo", mobileNo);
                thirdParamMap.put("isPrePay", isPrePay);
                thirdParamMap.put("twqtcId", twqtcId);
                thirdParamMap.put("contractNo", contractNo);
                thirdParamMap.put("customerName", customerName);
                thirdParamMap.put("wiliName", wiliName);
                order.setThirdData(JSONStringBuilder.getAjaxString(thirdParamMap));
                order.setPayTchannel(payTchannel.longValue());
                order.setCardTypeN(send.getCardTypeN());//1 磁条卡 2 IC卡
                order.setTransTerminalId(transTerminalId);

//				long sendId = addedOrderService.insertOrder(send, order);
//				send.setId(sendId);
//				//去支付
//				PurchaseResult rs = null;
//				switch(tp.getPayTchannel().intValue()){
//					case 4: rs = lianYiJiaService.fdPurchase(send);break;
//					default:rs = hanxinService.purchase(send,0.004);
//				}
                Map<String, Object> result = new HashMap<String, Object>();
                PurchaseResult rs = payOrder(send, order);
                if (0 == rs.getStatus()) {//
                    log.debug("支付失败");
                    result.clear();
                    result.put("reqCode", rs.getReqCode());
                    result.put("reqMsg", rs.getReqMsg());
                    //修改订单
                    addedOrderService.receivablesError(order.getId(), 0, rs.getReqCode(), rs.getReqMsg());
                    qian4SendLogService.updateResCodeMassage(send.getId(), rs.getReqCode(), rs.getReqMsg());
                } else {
                    order = addedOrderService.purchaseResolveResult(order, send, rs);

                    //log.debug("我要收款时, 收款成功！");
                    qian4SendLogService.updateResCodeMassage(send.getId(), order.getReqCode(), order.getReqMsg());
                    result.put("reqCode", order.getReqCode());
                    result.put("reqMsg", order.getReqMsg());
                    if ("0000".equals(order.getReqCode())) {
//						result = watercoal.Notify(item, extTypeCode, wiliCode, wltiId, billTypeCode, userNo, payAmount, amount, leePayAmount, balanceAmount, billDate, mobileNo, isPrePay, twqtcId, contractNo, orderNum);
//						//测试数据
//						result = new HashMap<String, Object>();
//						result.put("reqCode", "0000");
//						result.put("reqMsg", "缴费成功！");
//						result.put("tranestockSeq", TimeUtils.getDateTimeToString());

                        if ("0000".equals(result.get("reqCode"))) {
                            addedOrderService.updateThirdCodeAndMsg(order.getId(), 1, result.get("reqCode").toString(), result.get("reqMsg").toString(), result.get("tranestockSeq").toString());

                            //小票
                            result.put("category", orderType.get(order.getOrderTypeId()));
                            result.put("status", order.getStatus());
                            result.put("orderNum", order.getOrderNum());
                            result.put("transTime", DateConvertUtil.dateString(order.getCreateDate(), "HH:mm:ss"));
                            String cParam = terminalTypeId + "_" + order.getId();
                            String cParamB64 = new String(Des3.encodeXP(cParam));
                            result.put("certificateUrl", Certificate + cParamB64);
                            result.put("merchantName", Q4BaseAction.MERCHANT_NAME);//商户名称
                            result.put("merchantId", Q4BaseAction.MERCHANT_ID);//商户编号
                            result.put("terminalId", send.getTerminalId());//终端编号
                            String acquirersName = user.getOpeningBank();
                            if (null != acquirersName) {
                                acquirersName = acquirersName.replace("中国", "");
                            }
                            result.put("acquirersName", null != acquirersName ? acquirersName : order.getIssueBank());//收单行
                            result.put("issueBank", null == order.getIssueBank() ? "" : order.getIssueBank());//发卡行
                            result.put("bankCard", order.getBankCard());//收款卡号
                            result.put("cardType", null == order.getCardType() ? "" : order.getCardType());//收款卡号
                            result.put("expireDate", null == order.getExpireDate() ? "" : order.getExpireDate());//卡有效期（预授权时）
                            result.put("batchId", null == order.getBatchId() ? "" : order.getBatchId());//批次号
                            result.put("authorizationCode", null == order.getAuthorizationCode() ? "" : order.getAuthorizationCode());//授权码
                            result.put("bankTransTime", DateConvertUtil.dateString(order.getCreateDate(), "yyyy/MM/dd"));//日期/时间  transPriorSettle.getBankTransTime()
                            result.put("transMoney", order.getTransMoney());//交易金额
                            result.put("bankRef", order.getBankRef());//参考号
                            result.put("searchId", order.getSearchId());//凭证号
                            result.put("transId", order.getBankOrderNum());//银联交易流水号
                        } else {
                            addedOrderService.updateThirdCodeAndMsg(order.getId(), 4, result.get("reqCode").toString(), result.get("reqMsg").toString(), null);
                            //撤销订单
                            revocationOrderTimeOut(send, order.getId());
                        }
                    }
                }
                //检测 银联返回结果 如果是有违法嫌疑的  那么将暂停该笔结算
                transRefuseCardService.checkRefuseClear(userId, rs.getReqMsg(), order.getOrderNum(), order.getOrderTypeId());
                sendAppMsg(result);
            } else {

            }
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

    public String getCityName(String item, String key) throws Exception {
        return allCityHash.get(item).get(key);
    }

    public static void main(String[] args) {
        String s = "000|操作成功##重庆,32#重庆,394|安徽,3#宣城,50#合肥,3401#蚌埠,37#淮南,43#马鞍山,46|福建,4#福州,53#厦门,60|广东,6#广州,76#深圳,77#汕头,88|黑龙江,12#哈尔滨,167|湖北,13#武汉,180|湖南,14#长沙,197|江西,17#南昌,233|江苏,16#南京,220#苏州,221#常州,223#盐城,230|辽宁,18#沈阳,244|山西,23#太原,300|山东,22#济南,283|上海,25#上海,321|浙江,31#宁波,388|云南,30#昆明,367";
        String[] array = s.split("##");
        String s1 = array[0];
        String s2 = array[1];
        String[] array1 = s1.split("\\|");
        if ("000".equals(array1[0])) {
            String[] provinceCityA = s2.split("\\|");
            for (String pCity : provinceCityA) {
                String[] pCityA = pCity.split("#");
                for (String p : pCityA)
                    log.debug(p);
            }
        }
    }

}
